<!DOCTYPE html>
<title>Element#requestFullscreen() for non-top element in fullscreen element stack</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../trusted-click.js"></script>
<div id="log"></div>
<div id="first">
    <div id="last"></div>
</div>
<script>
async_test(function(t)
{
    var first = document.getElementById("first");
    trusted_request(t, first);
    document.onfullscreenchange = t.step_func(function()
    {
        assert_equals(document.fullscreenElement, first);
        var last = document.getElementById("last");
        trusted_request(t, last);
        document.onfullscreenchange = t.step_func(function()
        {
            assert_equals(document.fullscreenElement, last);
            trusted_request(t, first, last);
            document.onfullscreenchange = t.step_func_done(function() {
                assert_equals(document.fullscreenElement, first);
            });
        });
    });
});
</script>
